//买卖股票的最佳时机 Ⅱ（medium）: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/
class Solution
{
public:
	int maxProfit(vector<int>& p)
	{
		// 实现⽅式⼀：双指针
		int ret = 0, n = p.size();
		for (int i = 0; i < n; i++)
		{
			int j = i;
			while (j + 1 < n && p[j + 1] > p[j])
			{
				j++; // 找上升的末端
			}
			ret += p[j] - p[i];
			i = j;
		}
		return ret;
	}
};
class Solution
{
public:
	int maxProfit(vector<int>& prices)
	{
		// 实现⽅式⼆：拆分成⼀天⼀天
		int ret = 0;
		for (int i = 1; i < prices.size(); i++)
		{
			if (prices[i] > prices[i - 1])
			{
				ret += prices[i] - prices[i - 1];
			}
	
		}
		return ret;
	}
};